---
title: project-graph
---

import VersionLabel from '@site/src/components/Docs/VersionLabel';

The `moon project-graph [id]` (or `moon pg`) command will generate and serve a visual graph of all
configured projects as nodes, with dependencies between as edges, and can also output the graph in
[Graphviz DOT format](https://graphviz.org/doc/info/lang.html).

```shell
# Run the visualizer locally
$ moon project-graph

# Export to DOT format
$ moon project-graph --dot > graph.dot
```

> A project name can be passed to focus the graph to only that project and its dependencies. For
> example, `moon project-graph app`.

### Arguments

- `[name]` - Optional name or alias of a project to focus, as defined in
  [`projects`](../config/workspace#projects).

### Options

- `--dependents` - Include direct dependents of the focused project.
- `--dot` - Print the graph in DOT format.
- `--host` - The host address. Defaults to `127.0.0.1`. <VersionLabel version="1.36.0" />
- `--json` - Print the graph in JSON format.
- `--port` - The port to bind to. Defaults to a random port. <VersionLabel version="1.36.0" />

### Configuration

- [`projects`](../config/workspace#projects) in `.moon/workspace.yml`

## Example output

The following output is an example of the graph in DOT format.

```dot
digraph {
    0 [ label="(workspace)" style=filled, shape=circle, fillcolor=black, fontcolor=white]
    1 [ label="runtime" style=filled, shape=circle, fillcolor=gray, fontcolor=black]
    2 [ label="website" style=filled, shape=circle, fillcolor=gray, fontcolor=black]
    0 -> 1 [ arrowhead=none]
    0 -> 2 [ arrowhead=none]
}
```
